const App = getApp();

import moment from '../../../utils/moment'
import Dialog from '../../../weapp/dialog/dialog'
import Toast from '../../../weapp/toast/toast';
// components/list/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    type: Number,
    styleP: Boolean,
    strs: String,
    cusPageIndex: Number
  },

  /**
   * 组件的初始数据
   */
  data: {
    title: '我的客户',
    type: 2,    //客户类型
    timeData: {},
    remind_time: '',
    deviceList: [],    //列表
    deviceTotal: 0,    //总数
    devicePages: 0,     //总页数
    deviceIndex: 1,      //当前页 
    searchLoading: false, //加载更多
    deviceNoData: false,  //暂无更多
    searchLoadingComplete: false, //加载到底部
    see_show:0
  },
  lifetimes: {
    ready: function () {
      // this.getCustomersList()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    onChange(e) {
      this.setData({
        timeData: e.detail,
      });
      // console.log(e)
    },
    /**
     * 获取首页客户列表数据
     */
      //拨打电话
    makePhoneCall(e) {
      console.log(111)
      wx.makePhoneCall({
        phoneNumber: e.currentTarget.dataset.tel,
       
        success: function () {
          console.log('拨打成功')
        },
        fail: function () {
          console.log('拨打失败')
        }
      })
      
    },

    
    getCustomersList(keywords) {
      console.log(keywords)
      let _this = this
      // console.log(this.type)
      // wx.showLoading({
      //   title: '加载中...',
      // })
      App._post_form('Operation/getInvalidClue', {
        page: _this.data.deviceIndex,
        // action:'inspect',
        // type:'2',
        keywords,
      }, function (result) {
        // return false
        wx.hideLoading()
        //_this.filterList(result.data.list)
       let Result = result.data.data
        // let Result = result.data.list.map(el=>{
        //           const mobile = _this.mobileStr(el.mobile);
        //   console.log(mobile )
        //           return {...el, mobile}
        //         })
        // 响应无数据 则提示无数据
        if (_this.data.deviceIndex == 1 && Result.length == 0) {
          _this.setData({
            deviceNoData: true,
            searchLoading: false,
            searchLoadingComplete: false
          })
        }
        if (Result.length) {
          _this.data.deviceTotal = result.data.count
          _this.data.devicePages = result.data.total_page
          let deviceListTemp = [];
          if (_this.data.deviceIndex > 1) {
            deviceListTemp = _this.data.deviceList.concat(Result);
            console.log(deviceListTemp)
            _this.setData({
              searchLoading: true, //"正在载入更多"显示
            });
          } else {
            deviceListTemp = Result;
          }
          _this.setData({
            deviceList: deviceListTemp, //获取数据数组
            deviceNoData: false //“没有数据”隐藏
          });
        }
      });
    },
  
  }
})
